<?php

include('../model/db.php');

//$values['province'] = $_POST['province'];
//$values['color'] = $_POST['color'];
//$values['map'] = $_POST['map'];

//$province = $_POST['province'];
//$color = $_POST['color'];
//
//$data = "{'$unitid' : [";
//$data .= "'province' : '$province',";
//$data .= "'color' : '$color',";
//$data .= "'map' : '$map']}";

$data = $_POST['armyinfo'];
$unitid = $_POST['unitid'];
$map = $_POST['map'];
$data = json_encode($data);
//print_r($data);

mkdir("../images/$map/units");
$writefile = fopen("../images/$map/units/" . $unitid . ".json", "w");
fwrite($writefile, $data);
fclose($writefile);

//print_r($jsonarray);

//insert_to_db($values,"army");

?>